package Controll;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Dao.CommentDao;

public class BCommentInsertServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public BCommentInsertServlet() {
		super();
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		String username = request.getParameter("usname");
		String context = request.getParameter("context");
		CommentDao commentDao = new CommentDao();
		try {
			commentDao.binsert(username, context);
			request.setAttribute("message1", "评论成功");
		} catch (SQLException e) {
			e.printStackTrace();
		}
		request.getRequestDispatcher("mountainBai.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
